package com.dkd.spare.service.impl;

import java.util.List;
import com.dkd.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dkd.spare.mapper.SpareMapper;
import com.dkd.spare.domain.Spare;
import com.dkd.spare.service.ISpareService;

/**
 * 备件库存Service业务层处理
 * 
 * @author xzj
 * @date 2025-09-03
 */
@Service
public class SpareServiceImpl implements ISpareService 
{
    @Autowired
    private SpareMapper spareMapper;

    /**
     * 查询备件库存
     * 
     * @param id 备件库存主键
     * @return 备件库存
     */
    @Override
    public Spare selectSpareById(Long id)
    {
        return spareMapper.selectSpareById(id);
    }

    /**
     * 查询备件库存列表
     * 
     * @param spare 备件库存
     * @return 备件库存
     */
    @Override
    public List<Spare> selectSpareList(Spare spare)
    {
        return spareMapper.selectSpareList(spare);
    }

    /**
     * 新增备件库存
     * 
     * @param spare 备件库存
     * @return 结果
     */
    @Override
    public int insertSpare(Spare spare)
    {
        spare.setCreateTime(DateUtils.getNowDate());
        return spareMapper.insertSpare(spare);
    }

    /**
     * 修改备件库存
     * 
     * @param spare 备件库存
     * @return 结果
     */
    @Override
    public int updateSpare(Spare spare)
    {
        spare.setUpdateTime(DateUtils.getNowDate());
        return spareMapper.updateSpare(spare);
    }

    /**
     * 批量删除备件库存
     * 
     * @param ids 需要删除的备件库存主键
     * @return 结果
     */
    @Override
    public int deleteSpareByIds(Long[] ids)
    {
        return spareMapper.deleteSpareByIds(ids);
    }

    /**
     * 删除备件库存信息
     * 
     * @param id 备件库存主键
     * @return 结果
     */
    @Override
    public int deleteSpareById(Long id)
    {
        return spareMapper.deleteSpareById(id);
    }
}
